'use strict';
/**
 * Created by deng on 16-1-19.
 */

angular.module('metalabPartnerApp').config(['$stateProvider', function ($stateProvider) {
    $stateProvider.state('meta.account', {
        abstract: true,
        url: '/account',
        views: {
            'body@meta': {
                templateUrl: 'views/account/account.html'
            }
        }
    }).state('meta.account.info', {
        url: '/info',
        views: {
            'account@meta.account': {
                templateUrl: 'views/account/info.html',
                controller: 'InfoCtrl'
            }
        }
    }).state('meta.account.fund', {
        url: '/fund?page',
        params: {
            page: {
                value: '1',
                squash: false
            }
        },
        resolve: {
            accountRecord: function ($rootScope, MetaResources, $q) {
                var defer = $q.defer();
                $rootScope.passport.promise.then(function () {
                    MetaResources.accountRecord.query({
                        'userId': '_self',
                        '_range': '1_1',
                        '_sort': '-createdAt'
                    }, function (data) {
                        defer.resolve(data);
                    });
                });
                return defer.promise;
            }
        },
        views: {
            'account@meta.account': {
                templateUrl: 'views/account/fund.html',
                controller: 'FundCtrl'
            }
        }
    }).state('meta.account.password', {
        url: '/password',
        views: {
            'account@meta.account': {
                templateUrl: 'views/account/password.html',
                controller: 'PasswordCtrl'
            }
        }
    });
}]);
